﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ChinaSoft.Web.Model_tb_MidSoft_RoleHavePower
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int RoleHavePowerId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(RoleHavePowerId);
				}
			}
		}
			
	private void ShowInfo(int RoleHavePowerId)
	{
		ChinaSoft.BLL.BLL_tb_MidSoft_RoleHavePower bll=new ChinaSoft.BLL.BLL_tb_MidSoft_RoleHavePower();
		ChinaSoft.Model.Model_tb_MidSoft_RoleHavePower model=bll.GetModel(RoleHavePowerId);
		this.lblRoleHavePowerId.Text=model.RoleHavePowerId.ToString();
		this.txtRoleId.Text=model.RoleId.ToString();
		this.txtPowerId.Text=model.PowerId.ToString();
		this.txtCreateTime.Text=model.CreateTime.ToString();
		this.txtCreateUserId.Text=model.CreateUserId.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtRoleId.Text))
			{
				strErr+="角色ID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtPowerId.Text))
			{
				strErr+="权限ID格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCreateTime.Text))
			{
				strErr+="创建时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtCreateUserId.Text))
			{
				strErr+="创建人ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int RoleHavePowerId=int.Parse(this.lblRoleHavePowerId.Text);
			int RoleId=int.Parse(this.txtRoleId.Text);
			int PowerId=int.Parse(this.txtPowerId.Text);
			DateTime CreateTime=DateTime.Parse(this.txtCreateTime.Text);
			int CreateUserId=int.Parse(this.txtCreateUserId.Text);


			ChinaSoft.Model.Model_tb_MidSoft_RoleHavePower model=new ChinaSoft.Model.Model_tb_MidSoft_RoleHavePower();
			model.RoleHavePowerId=RoleHavePowerId;
			model.RoleId=RoleId;
			model.PowerId=PowerId;
			model.CreateTime=CreateTime;
			model.CreateUserId=CreateUserId;

			ChinaSoft.BLL.BLL_tb_MidSoft_RoleHavePower bll=new ChinaSoft.BLL.BLL_tb_MidSoft_RoleHavePower();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
